package com.example.gate.test;

import com.example.game.CResp;
import com.example.game.LoginResponse;
import io.netty.channel.*;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class WebSocketClientHandler extends SimpleChannelInboundHandler<CResp> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, CResp response) throws Exception {
        LoginResponse loginResponse = LoginResponse.parseFrom(response.getBody());

        log.info("收到WebSocket响应: id={}, code={}, ret={}, body={}",
                response.getId(), response.getCode(), response.getRet(),
                loginResponse.getUserInfo().getUsername());
    }
}